<?php
class Pingce_ctl extends Ctl{
    function __construct(){
    }
    function main(array $xxfget) {
        //$this::sessver();
        $type=!empty($_POST['type'])?$_POST['type']:false;
		$type=!empty($xxfget['type'])?$xxfget['type']:$type;
        if(!$type){
            $result=xdb::getInstance()->getarray("select * from pingjiao");
            $sj=xdb::getInstance()->getarray("select * from pingceshijuan order by id desc");
        	$this::show('pingcemanage',compact('result','sj'));
        }else{
            $this::$type($xxfget);
        }
    }
    function pingcesjm(){
        $result=xdb::getInstance()->getarray("select * from pingceshijuan where uid=".XXF_UID);
        $this->show("pingcesjm",compact('result'));
    }
    function pingceaddtitle($xxfget){
        $pcsjid=$xxfget['pcsjid'];
        $result=xdb::getInstance()->getarray("select * from pingceshijuantitle where pcsjid=$pcsjid");
        $this->show("pingcesjtitle",compact('result','pcsjid'));
    }
    function addpjobject($xxfget){
        $pjid=$xxfget['pjid'];
        $result=xdb::getInstance()->getarray("select * from pjobject where pjid=$pjid");
        $stuclass=xdb::getInstance()->getarray("select * from stuclass order by cname desc");
        $stuteacher=xdb::getInstance()->getarray("select * from stuteacher ");
        $this->show("pingceobject",compact('result','pjid','stuclass','stuteacher'));
    }
    function select($xxfget){
        $pjid=$xxfget['pjid'];
        $cnames=xdb::getInstance()->getcol("select DISTINCT cname from pjobject where pjid=$pjid order by cname");
        $this->show("pingceselect",compact('cnames','pjid'));
    }
    function exam($xxfget){
        $cname=urldecode(urldecode($xxfget['cname']));
        $pjid=$xxfget['pjid'];
        $result=xdb::getInstance()->getarray("select * from pjobject where pjid=$pjid and cname like '$cname'");
        $this->show("pingceexam",compact('result','cname','pjid'));
    }
    function pingceresult(){
        $ip=_fangwenip();
        $stime=$_POST['stime'];
        $result=$_POST['result'];
        $temstuid=time().rand(100,999);
        foreach ($result as $k=>$row){
            $array=array();
            $array2=array();
            $array['pjoid']=explode("_", $k)[1];
            $array['ip']=$ip;
            $array['stime']=$stime;
            $array['pjcontent']=$row['pjcontent'];
            $array['fen']=$row['fen'];
            $array['beizhu']=$row['beizhu'];
            $array['temstuid']=$temstuid;
            $array2['id']=0;
            xdb::getInstance()->indb("pjresult", $array, $array2);
        }
        echo 1;
    }
    function pingceresultshow($xxfget){
        $pjoid=$xxfget['pjoid'];
        $result=xdb::getInstance()->getarray("select * from pjresult where pjoid=$pjoid");
        $this->show("pingceresultshow",compact("result","pjoid"));
    }
}